package com.hundredapp.oa.web.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Repository;

import com.hundredapp.oa.dao.SelectType;
import com.hundredapp.oa.domain.OaContract;
import com.hundredapp.oa.repository.ContractManager;
import com.hundredapp.oa.util.JSEscape;
import com.opensymphony.xwork2.ActionSupport;

@Repository
@Scope("prototype")
public class Payment extends ActionSupport {
	
	@Autowired
	private ContractManager contractManager;
	
	private List<OaContract> pays ;
	
	private Integer paymentid;
	
	private Object success;
	
	private String msg;
	
	private int limit;
	
	private int start;
	
	private int total;
	
	private String query;

	public String allpay() {
		String condition = SelectType.SELECT_ALL;
		if(query != null) {
			query = JSEscape.unescape(query);
			condition += " and contractId like '%" +query+"%' ";
		}
		
		pays = contractManager.find(condition, start, limit);
		total = contractManager.count(condition);
		return SUCCESS;
	}
	
	public String delete() {
		contractManager.delete(paymentid);
		return SUCCESS;
	}

	public List<OaContract> getPays() {
		return pays;
	}

	public Object getSuccess() {
		return success;
	}

	public String getMsg() {
		return msg;
	}

	public void setPaymentid(Integer paymentid) {
		this.paymentid = paymentid;
	}

	public int getTotal() {
		return total;
	}

	public void setLimit(int limit) {
		this.limit = limit;
	}

	public void setStart(int start) {
		this.start = start;
	}

	public void setQuery(String query) {
		this.query = query;
	}

	public void setContractManager(ContractManager contractManager) {
		this.contractManager = contractManager;
	}
	
	
}
